﻿<UserControl x:Class="MediaBrowserSL.RIA.Views.PagePicturesView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:jadeControls="http://www.sebastien-alves.fr/jadeToolsSLControls"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:eventToCmd="clr-namespace:JulMar.Siverlight.Helpers.Interactivity;assembly=JulMar.Siverlight.Helpers"
    mc:Ignorable="d"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:julmarConverter="clr-namespace:JulMar.Silverlight.Converters;assembly=JulMar.Siverlight.Helpers"
    xmlns:bindingHelpers="clr-namespace:JulMar.Siverlight.Helpers.BindingHelpers;assembly=JulMar.Siverlight.Helpers"
    d:DesignHeight="300" d:DesignWidth="400">

    <UserControl.DataContext>
        <Binding Mode="OneWay" Path="Pictures" Source="{StaticResource Locator}"/>
    </UserControl.DataContext>

    <UserControl.Resources>
        <julmarConverter:NotBooleanConverter x:Key="notBooleanConverter" />
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="250"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <!--LEFT-->
            <Grid Grid.Column="0" Margin="10,10,10,10">


                <Grid.RowDefinitions>
                    <RowDefinition Height="20"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <Border Grid.Row="0" BorderThickness="1,1,1,0" CornerRadius="0,0,1,1" Background="{StaticResource BackGrdCustom}" BorderBrush="{StaticResource NormalBorderBrush}">
                    <sdk:Label Content="Dossiers" Foreground="White" Margin="5,0,0,0" />
                </Border>

                <Border Grid.Row="1" BorderThickness="2,0,2,2" CornerRadius="0,0,4,4" Padding="4" BorderBrush="{StaticResource NormalBorderBrush}">

                    <Border.Background>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#19000000" Offset="0"/>
                            <GradientStop Color="#6656747A" Offset="1"/>
                        </LinearGradientBrush>
                    </Border.Background>

                    <Grid>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="30"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="30"/>
                        </Grid.RowDefinitions>

                        <StackPanel x:Name="bd"
                    Grid.Row="0"
                    Orientation="Horizontal"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Center">
                            <TextBox x:Name="tbSearch" Width="150" Text="{Binding MediaLookFor, Mode=TwoWay}" bindingHelpers:BindingTextHelper.UpdateSourceOnChange="True" />
                        </StackPanel>

                        <ListBox x:Name="lMedias" ItemsSource="{Binding Path=MediasView}" DisplayMemberPath="Name" 
                                 IsEnabled="{Binding IsDroping, Converter={StaticResource notBooleanConverter}}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                                 Grid.Row="1" Background="{x:Null}">
                        </ListBox>

                        <Grid Grid.Row="2" Visibility="Visible">
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" >
                                <TextBox Text="{Binding NewMedia.Name, Mode=TwoWay}" VerticalAlignment="Center" Margin="2,0,5,0" HorizontalAlignment="Stretch" Width="112"  />
                                <jadeControls:ImageButton x:Name="btAdd" Command="{Binding AddFolderCommand}" ToolTipService.ToolTip="Ajouter un dossier"  Source="/MediaBrowserSL.RIA;component/Images/folder_add.png" Height="20" Margin="0,0,5,0" />
                                <jadeControls:ImageButton x:Name="btUp" Command="{Binding UpdateFolderCommand}" ToolTipService.ToolTip="Modifier ce dossier" Source="/MediaBrowserSL.RIA;component/Images/folder_edit.png" Height="20" Margin="0,0,5,0" />
                                <jadeControls:ImageButton Command="{Binding DeleteFolderCommand}" ToolTipService.ToolTip="Supprimer ce dossier" Source="/MediaBrowserSL.RIA;component/Images/folder_delete.png" Height="20" Margin="0,0,5,0" />
                                <jadeControls:Loading IsLoading="{Binding IsSaving}" />
                            </StackPanel>
                        </Grid>

                    </Grid>


                </Border>
            </Grid>
            <!--LEFT-->
            
            <jadeControls:Viewer Grid.Column="1" Margin="10,10,10,10" ItemsSource="{Binding Path=MediaItemsView}"  DisplayMemberPath="UrlImage" AllowDrop="True"
                                 IsEnabled="{Binding IsDroping, Converter={StaticResource notBooleanConverter}}">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Drop">
                        <eventToCmd:EventToCommand Command="{Binding DropItemCommand}" />
                    </i:EventTrigger>
                    <i:EventTrigger EventName="KeyDown">
                        <eventToCmd:EventToCommand Command="{Binding DeleteItemCommand}" />
                    </i:EventTrigger>
                    <i:EventTrigger EventName="DoubleClick">
                        <eventToCmd:EventToCommand Command="{Binding ViewItemCommand}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </jadeControls:Viewer>

            <jadeControls:Loading Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" IsLoading="{Binding IsDroping}" />

        </Grid>
    </Grid>
</UserControl>
